package com.aw.jsr303.ejemplo001;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * User: gmc
 * Date: 30/06/2010
 */
public class RucInfoValidator implements ConstraintValidator<RucInfoChecker, ComprobanteDePago> {

    public void initialize(RucInfoChecker annotation) {

    }

    public boolean isValid(ComprobanteDePago comprobanteDePago, ConstraintValidatorContext constraintValidatorContext) {
        if (comprobanteDePago.getTipo() == ComprobanteTipo.FACTURA){
            String ruc =comprobanteDePago.getRuc();
            return ruc != null && !"".equals(ruc);
        }
        return true;
    }

}